Repository navigation
Add onLongPress to TextInput - #59148
Open
YevheniiKotyrlo wants to merge 1 commit into
Open
YevheniiKotyrlo wants to merge 1 commit into
YevheniiKotyrlo wants to merge 1 commit into
Conversation
|
Warning JavaScript API change detected This PR commits an update to
This change was flagged as: |
YevheniiKotyrlo
force-pushed
the
feature/text-input-on-long-press
branch
from
October 23, 2026 19:48
39a8fd0 to
3664cc4
Compare
TextInput already handles its presses through Pressability and exposes onPress, onPressIn and onPressOut, but not onLongPress, so a held press on a TextInput cannot be told apart from a tap. TextInput now hands onLongPress to Pressability. Once a touch is held past the long press delay, onLongPress is called, and the release that follows does not call onPress, as on Pressable. That release is where TextInput focuses itself, so the input is focused when onLongPress fires instead; without that, a held field with contextMenuHidden on Android ends focused by the platform with no keyboard. Without onLongPress a held press is still a press.
YevheniiKotyrlo
force-pushed
the
feature/text-input-on-long-press
branch
from
October 23, 2026 23:35
3664cc4 to
77ea664
Compare
YevheniiKotyrlo
marked this pull request as ready for review
October 24, 2026 09:44
This branch has not been deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.



Summary:
TextInputalready handles its touches throughPressabilityand exposesonPress,onPressInandonPressOut, but notonLongPress, so a component cannot tell a held press on a field from a tap. #39701 addedonPresson the same grounds.This passes
onLongPressto thePressabilityconfigTextInputalready builds. A touch held past the long press delay calls it, and the release that follows calls noonPress, as onPressable. That release is whereTextInputfocuses itself, so the input is focused whenonLongPressfires instead; without that, a held field withcontextMenuHiddenon Android ends focused by the platform with no keyboard. WithoutonLongPress, a held press is still a press.I need it for a one-time-code field that sets
contextMenuHiddenon Android and offers its own Paste on a long press.Changelog:
[GENERAL] [ADDED] - Add
onLongPresstoTextInputTest Plan:
Four Fantom cases in
TextInput-itest.jsunderonLongPress: a touch held past the delay calls it once; it focuses the input when it fires, and the release that follows calls noonPress; a press released before the delay still callsonPressand focuses; and withoutonLongPressa held press still callsonPressand focuses. Onmainthe first two fail (onLongPressis called 0 times; no focus command is sent when the delay passes); with this change the file passes, 38 of 38.yarn flow-check,yarn lint,yarn test-typescript-legacy,yarn build-types(theReactNativeApi.d.tssnapshot gainsonLongPressonTextInputBaseProps),yarn test-generated-typescriptandyarn test-cipass. Mounting and updating 100TextInputs in a Fantom benchmark, with and withoutonLongPress, costs the same onmainas with this change, within the spread between runs.On an iPhone 12 Pro Max (iOS 27.0.1) with Xcode 27.1, where CI pins 16.4, RNTester's Debug and Release builds pass. So do 159 of
RNTesterUnitTests' 179 tests, with 10 skipped. The 10 that fail also fail onmain: fourRCTBundleURLProviderTeststhat read the device's packager setup,RCTConvert_NSColorTests testGenerateFallbackson iOS 27's colors, and the fiveRCTBlobManagerTests, whosesetUpstill sets thebridgekey that #59250 stopped synthesizing.Visual regression (ios)reportsswitch/custom-colors/toggledchanged by 11804 px, the same differencemain's own runs report onda42db9c90,f9340f07dcand11b10c0913.In RNTester's Playground:
Holding each field for 1.5 s and lifting, in RNTester debug builds on an Android 16 (API 36) emulator: on
mainnothing is logged while the finger is down andonPressis logged on release; with this changeonLongPressis logged while it is down and nothing on release. Both fields end focused with the keyboard up on both builds, and a tap logsonPresson both. Holding acontextMenuHiddenfield on its text leaves the keyboard down on both builds, because Android's own long press focuses the field first; #59130 stops that long press.